//
//  YCBaseViewController.m
//  HeartWorldClient
//
//  Created by 李珈旭 on 2016/10/21.
//  Copyright © 2016年 谭明权. All rights reserved.
//

#import "YCBaseViewController.h"

@interface YCBaseViewController ()

@property (nonatomic,strong)UIView *noDataView;

@end

@implementation YCBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.noDataView.backgroundColor = [UIColor clearColor];
}

-(void)noDataViewShowWithSuperView:(UIView *)superView andTitle:(NSString *)title{
    _noDataView = [[UIView alloc]initWithFrame:superView.bounds];
    _noDataView.height = superView.bounds.size.height - 64;
    _noDataView.backgroundColor = [UIColor clearColor];
    [superView addSubview:_noDataView];
    [superView bringSubviewToFront:_noDataView];
    UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 60, 100)];
    imageview.center = _noDataView.center;
    imageview.image = [UIImage imageNamed:@"noneDataImage"];
    [_noDataView addSubview:imageview];
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 150, 30)];
    label.text = title;
    label.font = [UIFont systemFontOfSize:15];
    label.textAlignment = NSTextAlignmentCenter;
    label.center = CGPointMake(_noDataView.centerX, imageview.frame.origin.y + 110);
    [_noDataView addSubview:label];
}

-(void)noDataViewShowWithSuperView:(UIView *)superView andTitle:(NSString *)title andFrame:(CGRect)frame
{
    _noDataView  = [[UIView alloc]initWithFrame:CGRectMake(0, 170,SCREEN_WIDTH, superView.height  - 170 - 49)];
    _noDataView.frame = CGRectMake(0, 170,SCREEN_WIDTH, superView.height  - 170 - 49);
    _noDataView.backgroundColor = [UIColor clearColor];
    [superView addSubview:_noDataView];
    [superView bringSubviewToFront:_noDataView];
    UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 80, 80)];
    imageview.center = CGPointMake(_noDataView.width * 0.5, _noDataView.height * 0.5);
    imageview.image = [UIImage imageNamed:@"noneDataImage"];
    [_noDataView addSubview:imageview];
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 150, 30)];
    label.text = title;
    label.font = [UIFont systemFontOfSize:15];
    label.textAlignment = NSTextAlignmentCenter;
    label.center = CGPointMake(_noDataView.centerX, imageview.frame.origin.y + 80 + 18);
    [_noDataView addSubview:label];
}

-(void)noDataViewWhiteColorShowWithSuperView:(UIView *)superView andTitle:(NSString *)title
{
    _noDataView  = [[UIView alloc]initWithFrame:superView.bounds];
    _noDataView.height = superView.bounds.size.height - 64;
    _noDataView.backgroundColor = [UIColor whiteColor];
    [superView addSubview:_noDataView];
    [superView bringSubviewToFront:_noDataView];
    UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 80, 80)];
    imageview.center = _noDataView.center;
    imageview.image = [UIImage imageNamed:@"noneDataImage"];
    [_noDataView addSubview:imageview];
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 150, 30)];
    label.text = title;
    label.font = [UIFont systemFontOfSize:15];
    label.textAlignment = NSTextAlignmentCenter;
    label.center = CGPointMake(_noDataView.centerX, imageview.frame.origin.y + 80 + 18);
    [_noDataView addSubview:label];

}


-(void)removeNoDataView{
    [_noDataView removeFromSuperview];
}
@end
